﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class JobSearchByIndustry : System.Web.UI.Page
{
    string mode = "ByIndustry";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillIndustry();
        }
    }

    protected void FillIndustry()
    {
        try
        {
            clsEmployerDAL objclsSkillsMasterDAL = new clsEmployerDAL();
            List<IN_TB_EMPLOYER_MST> objIN_TB_SKILL_MST = new List<IN_TB_EMPLOYER_MST>();
            objIN_TB_SKILL_MST = objclsSkillsMasterDAL.GetAllEmployer(); ;
            rptSkills.DataSource = objIN_TB_SKILL_MST;
            rptSkills.DataBind();
        }
        catch (Exception)
        {

            throw;
        }
    }

    protected void rptSkills_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (Convert.ToString(e.CommandName) == "SkillsSearch")
        {
            string industry = Convert.ToString(e.CommandArgument);
            if (industry != "")
            {
                mode = clsEncryptionDecryption.EncryptQueryString(mode);
                Response.Redirect("JobSearchResult.aspx?mode=" + mode + "&industryset=" + clsEncryptionDecryption.EncryptQueryString(industry.Trim().ToLower()) + "&roleid=" + Convert.ToString(Request.QueryString["roleid"]));
            }

        }
    }

    protected void grdSeachByIndustry_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                HiddenField hfJobPostId = (HiddenField)e.Row.FindControl("hfJobPostId");
                LinkButton lnkApplyNow = (LinkButton)e.Row.FindControl("lnkApplyNow");
                Label lblAlreadyApplied = (Label)e.Row.FindControl("lblAlreadyApplied");
                if (Session["UserId"] != null && hfJobPostId.Value != "")
                {
                    clsJobsAppliedDAL objclsJobsAppliedDAL = new clsJobsAppliedDAL();
                    bool Result = objclsJobsAppliedDAL.IsJobApplied(Convert.ToInt32(Session["UserId"]), Convert.ToInt32(hfJobPostId.Value));
                    if (Result == true)
                    {
                        lblAlreadyApplied.Visible = true;
                        lnkApplyNow.Text = "Check Status";
                    }
                    else
                    {
                        lblAlreadyApplied.Visible = false;
                        lnkApplyNow.Text = "Apply";
                    }
                }
                if (Session["UserId"] == null)
                {
                    Response.Redirect("JobSeekerLogin.aspx");
                }
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
    protected void grdSeachByIndustry_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    }
    protected void btnSeachBySkills_Click(object sender, EventArgs e)
    {
        try
        {

        }
        catch (Exception)
        {

            throw;
        }
    }

    protected void btnClearSearch_Click(object sender, EventArgs e)
    {
        try
        {
            txtIndustry.Text = "";
            grdSeachByIndustry.DataSource = null;
            grdSeachByIndustry.DataBind();
        }
        catch (Exception)
        {

            throw;
        }
    }
}